local paoxiao = fk.CreateSkill {

  name = "joyex__paoxiao",

  tags = { Skill.Compulsory, },

}



paoxiao:addEffect("targetmod", {
  name = "joyex__paoxiao",
  frequency = Skill.Compulsory,
  residue_func = function(self, player, skill, scope)
    if player:hasSkill(paoxiao.name) and skill.trueName == "slash_skill"
      and scope == Player.HistoryPhase then
      return 999
    end
  end,
  bypass_distances = function(self, player, skill, scope)
    return player:hasSkill(paoxiao.name) and skill.trueName == "slash_skill" and player:usedCardTimes("slash", Player.HistoryPhase) > 0 and player.phase == Player.Play
  end,
})

paoxiao:addEffect(fk.CardUsing, {
  refresh_events = {fk.CardUsing},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill("joyex__paoxiao") and
      data.card.trueName == "slash" and
      player:usedCardTimes("slash") > 1
  end,
  on_refresh = function(self, event, target, player, data)
    player:broadcastSkillInvoke("joyex__paoxiao")
    player.room:doAnimate("InvokeSkill", {
      name = "joyex__paoxiao",
      player = player.id,
      skill_type = "offensive",
    })
  end,
})

return paoxiao